{% extends 'report.base.html' %}

{% load custom_tags %}

{% block main %}
  
  {% for itemname in items %}
  
  <h2>{{itemname}} Report</h2>

  <table>
    <tr>
      <th class="bg-gainsboro">Mentor</th>
      <th class="bg-gainsboro">Customer</th>
      <th class="bg-gainsboro">Quantity</th>
    </tr>

    {% for row in rows %}
      {% if row.item == itemname %}
      <tr>
        
        {% if row.mentor == '-' %}
          <td>{{row.mentor}}</td>
        {% else %}
          {% if row.group_orders_count > 0 %}
            <td rowspan="{{row.group_orders_count}}">{{row.mentor}}</td>
          {% endif %}
        {% endif %}

        {% if row.customer == 'total' %}
          <td class="font-bold bg-gainsboro">{{row.customer}}</td>
        {% else %}
          <td>{{row.customer}}</td>
        {% endif %}
        {% if row.customer == 'total' %}
          <td class="align-right font-bold bg-gainsboro">{{row.quantity}}</td>
        {% else %}
          <td class="align-right">{{row.quantity}}</td>
        {% endif %}
      </tr>
      {% endif %}
    {% endfor %}

    <tr>
      <td class="font-bold bg-grey" colspan="2">Total Quantity</td>
      <td class="align-right font-bold bg-grey">{% get_item_quantity qty_dict itemname %}</td>
    </tr>
  </table>

  {% endfor %}

{% endblock %}
